#include "qquickitem.h"
-#include "qquickcanvas.h"
+#include "qquickwindow.h"
#include <QtQml/qjsengine.h>
-#include "qquickcanvas_p.h"
+#include "qquickwindow_p.h"
#include "qquickevents_p_p.h"
#include "qquickscreen_p.h"
\ingroup qtquick-visual-transforms
\brief For specifying advanced transformations on Items
- The Transform element is a base type which cannot be instantiated directly.
+ The Transform type is a base type which cannot be instantiated directly.
The following concrete Transform types are available:
\list
\li \l Translate
\endlist
- The Transform elements let you create and control advanced transformations that can be configured
+ The Transform types let you create and control advanced transformations that can be configured
independently using specialized properties.
- You can assign any number of Transform elements to an \l Item. Each Transform is applied in order,
+ You can assign any number of Transforms to an \l Item. Each Transform is applied in order,
one at a time.
*/
The Translate object provides independent control over position in addition to the Item's x and y properties.
- The following example moves the Y axis of the \l Rectangle elements while still allowing the \l Row element
+ The following example moves the Y axis of the \l Rectangle items while still allowing the \l Row
to lay the items out as if they had not been transformed:
\qml
import QtQuick 2.0
\ingroup qtquick-visual-transforms
\brief Provides a way to scale an Item
- The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically,
+ The Scale type gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically,
it allows a different scale for the x and y axes, and allows the scale to be relative to an
arbitrary point.
{
Q_D(QQuickKeysAttached);
int signal_index = d->signalIndex(signalName);
- return QQml_isSignalConnected(this, signal_index);
+ return d->isSignalConnected(signal_index);
}
/*!
}
// first process forwards
- if (d->item && d->item->canvas()) {
+ if (d->item && d->item->window()) {
d->inPress = true;
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible()) {
- d->item->canvas()->sendEvent(i, event);
+ d->item->window()->sendEvent(i, event);
if (event->isAccepted()) {
d->inPress = false;
return;
return;
}
- if (d->item && d->item->canvas()) {
+ if (d->item && d->item->window()) {
d->inRelease = true;
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible()) {
- d->item->canvas()->sendEvent(i, event);
+ d->item->window()->sendEvent(i, event);
if (event->isAccepted()) {
d->inRelease = false;
return;
void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post)
{
Q_D(QQuickKeysAttached);
- if (post == m_processPost && d->item && !d->inIM && d->item->canvas()) {
+ if (post == m_processPost && d->item && !d->inIM && d->item->window()) {
d->inIM = true;
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible() && (i->flags() & QQuickItem::ItemAcceptsInputMethod)) {
- d->item->canvas()->sendEvent(i, event);
+ d->item->window()->sendEvent(i, event);
if (event->isAccepted()) {
d->imeItem = i;
d->inIM = false;
\brief Property used to mirror layout behavior
The LayoutMirroring attached property is used to horizontally mirror \l {anchor-layout}{Item anchors},
- \l{Using QML Positioner and Repeater Items}{positioner} elements (such as \l Row and \l Grid)
+ \l{Using QML Positioner and Repeater Items}{positioner} types (such as \l Row and \l Grid)
and views (such as \l GridView and horizontal \l ListView). Mirroring is a visual change: left
- anchors become right anchors, and positioner elements like \l Grid and \l Row reverse the
+ anchors become right anchors, and positioner types like \l Grid and \l Row reverse the
horizontal layout of child items.
Mirroring is enabled for an item by setting the \l enabled property to true. By default, this
only affects the item itself; setting the \l childrenInherit property to true propagates the mirroring
- behavior to all child elements as well. If the \c LayoutMirroring attached property has not been defined
+ behavior to all child items as well. If the \c LayoutMirroring attached property has not been defined
for an item, mirroring is not enabled.
The following example shows mirroring in action. The \l Row below is specified as being anchored
This property holds whether the item's layout is mirrored horizontally. Setting this to true
horizontally reverses \l {anchor-layout}{anchor} settings such that left anchors become right,
- and right anchors become left. For \l{Using QML Positioner and Repeater Items}{positioner} elements
- (such as \l Row and \l Grid) and view elements (such as \l {GridView}{GridView} and \l {ListView}{ListView})
+ and right anchors become left. For \l{Using QML Positioner and Repeater Items}{positioner} types
+ (such as \l Row and \l Grid) and view types (such as \l {GridView}{GridView} and \l {ListView}{ListView})
this also mirrors the horizontal layout direction of the item.
The default value is false.
anchor_d->fillChanged();
anchor_d->centerInChanged();
anchor_d->updateHorizontalAnchors();
- emit _anchors->mirroredChanged();
}
mirrorChange();
if (extra.isAllocated() && extra->layoutDirectionAttached) {
surface. Using scene graph API directly is always significantly
faster.
- \sa QQuickCanvas, QQuickPaintedItem
+ \sa QQuickWindow, QQuickPaintedItem
*/
/*!
\section1 Key Handling
- Key handling is available to all Item-based visual elements via the \l {Keys}{Keys}
+ Key handling is available to all Item-based visual types via the \l {Keys}{Keys}
attached property. The \e Keys attached property provides basic handlers such
as \l {Keys::onPressed}{onPressed} and \l {Keys::onReleased}{onReleased},
as well as handlers for specific keys, such as
Q_D(QQuickItem);
- if (d->canvasRefCount > 1)
- d->canvasRefCount = 1; // Make sure canvas is set to null in next call to derefCanvas().
+ if (d->windowRefCount > 1)
+ d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
if (d->parentItem)
setParentItem(0);
- else if (d->canvas)
- d->derefCanvas();
+ else if (d->window)
+ d->derefWindow();
// XXX todo - optimize
while (!d->childItems.isEmpty())
The default transform origin is \c Item.Center.
To set an arbitrary transform origin point use the \l Scale or \l Rotation
- transform elements.
+ transform types.
*/
/*!
scopeItem = oldParentItem;
while (!scopeItem->isFocusScope() && scopeItem->parentItem())
scopeItem = scopeItem->parentItem();
- if (d->canvas) {
- QQuickCanvasPrivate::get(d->canvas)->clearFocusInScope(scopeItem, scopeFocusedItem,
- QQuickCanvasPrivate::DontChangeFocusProperty);
+ if (d->window) {
+ QQuickWindowPrivate::get(d->window)->clearFocusInScope(scopeItem, scopeFocusedItem,
+ QQuickWindowPrivate::DontChangeFocusProperty);
if (scopeFocusedItem != this)
QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(this, true);
} else {
if (wasVisible) {
emit oldParentItem->visibleChildrenChanged();
}
- } else if (d->canvas) {
- QQuickCanvasPrivate::get(d->canvas)->parentlessItems.remove(this);
+ } else if (d->window) {
+ QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
}
- QQuickCanvas *oldParentCanvas = oldParentItem ? QQuickItemPrivate::get(oldParentItem)->canvas : 0;
- QQuickCanvas *parentCanvas = parentItem ? QQuickItemPrivate::get(parentItem)->canvas : 0;
- if (oldParentCanvas == parentCanvas) {
- // Avoid freeing and reallocating resources if the canvas stays the same.
+ QQuickWindow *oldParentWindow = oldParentItem ? QQuickItemPrivate::get(oldParentItem)->window : 0;
+ QQuickWindow *parentWindow = parentItem ? QQuickItemPrivate::get(parentItem)->window : 0;
+ if (oldParentWindow == parentWindow) {
+ // Avoid freeing and reallocating resources if the window stays the same.
d->parentItem = parentItem;
} else {
- if (oldParentCanvas)
- d->derefCanvas();
+ if (oldParentWindow)
+ d->derefWindow();
d->parentItem = parentItem;
- if (parentCanvas)
- d->refCanvas(parentCanvas);
+ if (parentWindow)
+ d->refWindow(parentWindow);
}
d->dirty(QQuickItemPrivate::ParentChanged);
if (d->parentItem)
QQuickItemPrivate::get(d->parentItem)->addChild(this);
- else if (d->canvas)
- QQuickCanvasPrivate::get(d->canvas)->parentlessItems.insert(this);
+ else if (d->window)
+ QQuickWindowPrivate::get(d->window)->parentlessItems.insert(this);
d->setEffectiveVisibleRecur(d->calcEffectiveVisible());
d->setEffectiveEnableRecur(0, d->calcEffectiveEnable());
QQuickItemPrivate::get(scopeFocusedItem)->focus = false;
emit scopeFocusedItem->focusChanged(false);
} else {
- if (d->canvas) {
- QQuickCanvasPrivate::get(d->canvas)->setFocusInScope(scopeItem, scopeFocusedItem,
- QQuickCanvasPrivate::DontChangeFocusProperty);
+ if (d->window) {
+ QQuickWindowPrivate::get(d->window)->setFocusInScope(scopeItem, scopeFocusedItem,
+ QQuickWindowPrivate::DontChangeFocusProperty);
} else {
QQuickItemPrivate::get(scopeFocusedItem)->updateSubFocusItem(scopeItem, true);
}
return d->parentItem;
}
-QQuickCanvas *QQuickItem::canvas() const
+QQuickWindow *QQuickItem::window() const
{
Q_D(const QQuickItem);
- return d->canvas;
+ return d->window;
}
static bool itemZOrder_sort(QQuickItem *lhs, QQuickItem *rhs)
emit q->childrenChanged();
}
-void QQuickItemPrivate::InitializationState::clear()
+void QQuickItemPrivate::refWindow(QQuickWindow *c)
{
- focusScope = 0;
-}
-
-void QQuickItemPrivate::InitializationState::clear(QQuickItem *fs)
-{
- focusScope = fs;
-}
-
-QQuickItem *QQuickItemPrivate::InitializationState::getFocusScope(QQuickItem *item)
-{
- if (!focusScope) {
- QQuickItem *fs = item->parentItem();
- while (fs->parentItem() && !fs->isFocusScope())
- fs = fs->parentItem();
- focusScope = fs;
- }
- return focusScope;
-}
-
-void QQuickItemPrivate::refCanvas(InitializationState *state, QQuickCanvas *c)
-{
- // An item needs a canvas if it is referenced by another item which has a canvas.
+ // An item needs a window if it is referenced by another item which has a window.
// Typically the item is referenced by a parent, but can also be referenced by a
- // ShaderEffect or ShaderEffectSource. 'canvasRefCount' counts how many items with
- // a canvas is referencing this item. When the reference count goes from zero to one,
- // or one to zero, the canvas of this item is updated and propagated to the children.
- // As long as the reference count stays above zero, the canvas is unchanged.
- // refCanvas() increments the reference count.
- // derefCanvas() decrements the reference count.
+ // ShaderEffect or ShaderEffectSource. 'windowRefCount' counts how many items with
+ // a window is referencing this item. When the reference count goes from zero to one,
+ // or one to zero, the window of this item is updated and propagated to the children.
+ // As long as the reference count stays above zero, the window is unchanged.
+ // refWindow() increments the reference count.
+ // derefWindow() decrements the reference count.
Q_Q(QQuickItem);
- Q_ASSERT((canvas != 0) == (canvasRefCount > 0));
+ Q_ASSERT((window != 0) == (windowRefCount > 0));
Q_ASSERT(c);
- if (++canvasRefCount > 1) {
- if (c != canvas)
- qWarning("QQuickItem: Cannot use same item on different canvases at the same time.");
- return; // Canvas already set.
+ if (++windowRefCount > 1) {
+ if (c != window)
+ qWarning("QQuickItem: Cannot use same item on different windows at the same time.");
+ return; // Window already set.
}
- Q_ASSERT(canvas == 0);
- canvas = c;
+ Q_ASSERT(window == 0);
+ window = c;
if (polishScheduled)
- QQuickCanvasPrivate::get(canvas)->itemsToPolish.insert(q);
-
- InitializationState _dummy;
- InitializationState *childState = state;
-
- if (q->isFocusScope()) {
- _dummy.clear(q);
- childState = &_dummy;
- }
+ QQuickWindowPrivate::get(window)->itemsToPolish.insert(q);
if (!parentItem)
- QQuickCanvasPrivate::get(canvas)->parentlessItems.insert(q);
+ QQuickWindowPrivate::get(window)->parentlessItems.insert(q);
for (int ii = 0; ii < childItems.count(); ++ii) {
QQuickItem *child = childItems.at(ii);
- QQuickItemPrivate::get(child)->refCanvas(childState, c);
+ QQuickItemPrivate::get(child)->refWindow(c);
}
- dirty(Canvas);
+ dirty(Window);
if (extra.isAllocated() && extra->screenAttached)
- extra->screenAttached->canvasChanged(c);
+ extra->screenAttached->windowChanged(c);
itemChange(QQuickItem::ItemSceneChange, c);
}
-void QQuickItemPrivate::derefCanvas()
+void QQuickItemPrivate::derefWindow()
{
Q_Q(QQuickItem);
- Q_ASSERT((canvas != 0) == (canvasRefCount > 0));
+ Q_ASSERT((window != 0) == (windowRefCount > 0));
- if (!canvas)
+ if (!window)
return; // This can happen when destroying recursive shader effect sources.
- if (--canvasRefCount > 0)
- return; // There are still other references, so don't set canvas to null yet.
+ if (--windowRefCount > 0)
+ return; // There are still other references, so don't set window to null yet.
q->releaseResources();
removeFromDirtyList();
- QQuickCanvasPrivate *c = QQuickCanvasPrivate::get(canvas);
+ QQuickWindowPrivate *c = QQuickWindowPrivate::get(window);
if (polishScheduled)
c->itemsToPolish.remove(q);
+ QMutableHashIterator<int, QQuickItem *> itemTouchMapIt(c->itemForTouchPointId);
+ while (itemTouchMapIt.hasNext()) {
+ if (itemTouchMapIt.next().value() == q)
+ itemTouchMapIt.remove();
+ }
if (c->mouseGrabberItem == q)
c->mouseGrabberItem = 0;
if ( hoverEnabled )
if (!parentItem)
c->parentlessItems.remove(q);
- canvas = 0;
+ window = 0;
itemNodeInstance = 0;
for (int ii = 0; ii < childItems.count(); ++ii) {
QQuickItem *child = childItems.at(ii);
- QQuickItemPrivate::get(child)->derefCanvas();
+ QQuickItemPrivate::get(child)->derefWindow();
}
- dirty(Canvas);
+ dirty(Window);
if (extra.isAllocated() && extra->screenAttached)
- extra->screenAttached->canvasChanged(0);
- itemChange(QQuickItem::ItemSceneChange, (QQuickCanvas *)0);
+ extra->screenAttached->windowChanged(0);
+ itemChange(QQuickItem::ItemSceneChange, (QQuickWindow *)0);
}
/*!
-Returns a transform that maps points from canvas space into item space.
+Returns a transform that maps points from window space into item space.
*/
-QTransform QQuickItemPrivate::canvasToItemTransform() const
+QTransform QQuickItemPrivate::windowToItemTransform() const
{
// XXX todo - optimize
- return itemToCanvasTransform().inverted();
+ return itemToWindowTransform().inverted();
}
/*!
-Returns a transform that maps points from item space into canvas space.
+Returns a transform that maps points from item space into window space.
*/
-QTransform QQuickItemPrivate::itemToCanvasTransform() const
+QTransform QQuickItemPrivate::itemToWindowTransform() const
{
// XXX todo
- QTransform rv = parentItem?QQuickItemPrivate::get(parentItem)->itemToCanvasTransform():QTransform();
+ QTransform rv = parentItem?QQuickItemPrivate::get(parentItem)->itemToWindowTransform():QTransform();
itemToParentTransform(rv);
return rv;
}
}
QQuickItemPrivate::QQuickItemPrivate()
-: _anchors(0), _stateGroup(0),
- flags(0), widthValid(false), heightValid(false), baselineOffsetValid(false), componentComplete(true),
- keepMouse(false), keepTouch(false), hoverEnabled(false), smooth(true), focus(false), activeFocus(false), notifiedFocus(false),
- notifiedActiveFocus(false), filtersChildMouseEvents(false), explicitVisible(true),
- effectiveVisible(true), explicitEnable(true), effectiveEnable(true), polishScheduled(false),
- inheritedLayoutMirror(false), effectiveLayoutMirror(false), isMirrorImplicit(true),
- inheritMirrorFromParent(false), inheritMirrorFromItem(false),
- isAccessible(false), culled(false),
-
- dirtyAttributes(0), nextDirtyItem(0), prevDirtyItem(0),
-
- canvas(0), canvasRefCount(0), parentItem(0), sortedChildItems(&childItems),
-
- subFocusItem(0),
-
- x(0), y(0), width(0), height(0), implicitWidth(0), implicitHeight(0),
-
- baselineOffset(0),
-
- itemNodeInstance(0), groupNode(0), paintNode(0)
+ : _anchors(0)
+ , _stateGroup(0)
+ , flags(0)
+ , widthValid(false)
+ , heightValid(false)
+ , baselineOffsetValid(false)
+ , componentComplete(true)
+ , keepMouse(false)
+ , keepTouch(false)
+ , hoverEnabled(false)
+ , smooth(true)
+ , antialiasing(false)
+ , focus(false)
+ , activeFocus(false)
+ , notifiedFocus(false)
+ , notifiedActiveFocus(false)
+ , filtersChildMouseEvents(false)
+ , explicitVisible(true)
+ , effectiveVisible(true)
+ , explicitEnable(true)
+ , effectiveEnable(true)
+ , polishScheduled(false)
+ , inheritedLayoutMirror(false)
+ , effectiveLayoutMirror(false)
+ , isMirrorImplicit(true)
+ , inheritMirrorFromParent(false)
+ , inheritMirrorFromItem(false)
+ , isAccessible(false)
+ , culled(false)
+ , dirtyAttributes(0)
+ , nextDirtyItem(0)
+ , prevDirtyItem(0)
+ , window(0)
+ , windowRefCount(0)
+ , parentItem(0)
+ , sortedChildItems(&childItems)
+ , subFocusItem(0)
+ , x(0)
+ , y(0)
+ , width(0)
+ , height(0)
+ , implicitWidth(0)
+ , implicitHeight(0)
+ , baselineOffset(0)
+ , itemNodeInstance(0)
+ , groupNode(0)
+ , paintNode(0)
{
}
explicit property changes. In such cases it may be better to use the
\l opacity property instead.)
- Setting this property to \c false automatically causes \l focus to be set
- to \c false, and this item will longer receive mouse and keyboard events.
- (In contrast, setting the \l opacity to 0 does not affect the \l focus
- property and the receiving of key events.)
+ If this property is set to \c false, the item will no longer receive mouse
+ events, but will continue to receive key events and will retain the keyboard
+ \l focus if it has been set. (In contrast, setting the \l enabled property
+ to \c false stops both mouse and keyboard events, and also removes focus
+ from the item.)
\note This property's value is only affected by changes to this property or
the parent's \c visible property. It does not change, for example, if this
item moves off-screen, or if the \l opacity changes to 0.
*/
+/*!
+ \qmlproperty bool QtQuick2::Item::enabled
+
+ This property holds whether the item receives mouse and keyboard events.
+ By default this is true.
+
+ Setting this property directly affects the \c enabled value of child
+ items. When set to \c false, the \c enabled values of all child items also
+ become \c false. When set to \c true, the \c enabled values of child items
+ are returned to \c true, unless they have explicitly been set to \c false.
+
+ Setting this property to \c false automatically causes \l activeFocus to be
+ set to \c false, and this item will longer receive keyboard events.
+*/
/*!
\qmlproperty AnchorLine QtQuick2::Item::anchors.top
\qmlproperty real QtQuick2::Item::anchors.verticalCenterOffset
\qmlproperty real QtQuick2::Item::anchors.baselineOffset
- \qmlproperty bool QtQuick2::Item::anchors.mirrored
\qmlproperty bool QtQuick2::Item::anchors.alignWhenCentered
Anchors provide a way to position an item by specifying its
Margins apply to top, bottom, left, right, and fill anchors.
The \c anchors.margins property can be used to set all of the various margins at once, to the same value.
+ It will not override a specific margin that has been previously set; to clear an explicit margin
+ set it's value to \c undefined.
Note that margins are anchor-specific and are not applied if an item does not
use anchors.
To clear an anchor value, set it to \c undefined.
- \c anchors.mirrored returns true it the layout has been \l {LayoutMirroring}{mirrored}.
-
\c anchors.alignWhenCentered (default true) forces centered anchors to align to a
whole pixel, i.e. if the item being centered has an odd width/height the item
will be positioned on a whole pixel rather than being placed on a half-pixel.
/*!
This function is called when the item's scene graph resources are no longer needed.
It allows items to free its resources, for instance textures, that are not owned by scene graph
- nodes. Note that scene graph nodes are managed by QQuickCanvas and should not be deleted by
+ nodes. Note that scene graph nodes are managed by QQuickWindow and should not be deleted by
this function. Scene graph resources are no longer needed when the parent is set to null and
the item is not used by any \l ShaderEffect or \l ShaderEffectSource.
* Schedules a call to updatePaintNode() for this item.
*
* The call to QQuickItem::updatePaintNode() will always happen if the
- * item is showing in a QQuickCanvas.
+ * item is showing in a QQuickWindow.
*
* Only items which specifies QQuickItem::ItemHasContents are allowed
* to call QQuickItem::update().
Q_D(QQuickItem);
if (!d->polishScheduled) {
d->polishScheduled = true;
- if (d->canvas) {
- QQuickCanvasPrivate *p = QQuickCanvasPrivate::get(d->canvas);
+ if (d->window) {
+ QQuickWindowPrivate *p = QQuickWindowPrivate::get(d->window);
bool maybeupdate = p->itemsToPolish.isEmpty();
p->itemsToPolish.insert(this);
- if (maybeupdate) d->canvas->maybeUpdate();
+ if (maybeupdate) d->window->maybeUpdate();
}
}
}
// invalid cases
if (ok) *ok = true;
- QTransform t = d->itemToCanvasTransform();
- if (other) t *= QQuickItemPrivate::get(other)->canvasToItemTransform();
+ QTransform t = d->itemToWindowTransform();
+ if (other) t *= QQuickItemPrivate::get(other)->windowToItemTransform();
return t;
}
if (d->extra.isAllocated() && d->extra->contents)
d->extra->contents->complete();
- if (d->canvas && d->dirtyAttributes) {
+ if (d->window && d->dirtyAttributes) {
d->addToDirtyList();
- QQuickCanvasPrivate::get(d->canvas)->dirtyItem(this);
+ QQuickWindowPrivate::get(d->window)->dirtyItem(this);
}
}
\endqml
\endtable
- If an item's opacity is set to 0, the item will no longer receive mouse
- events, but will continue to receive key events and will retain the keyboard
- \l focus if it has been set. (In contrast, setting the \l visible property
- to \c false stops both mouse and keyboard events, and also removes focus
- from the item.)
+ Changing an items opacity will not affect delivery of input events. (In contrast
+ setting \l visible property to \c false stops mouse events, and setting the
+ \l enabled property to \c false stops mouse and keyboard events, and also removes
+ active focus from the item.)
*/
/*!
dirty(Visible);
if (parentItem) QQuickItemPrivate::get(parentItem)->dirty(ChildrenStackingChanged);
- if (canvas) {
- QQuickCanvasPrivate *canvasPriv = QQuickCanvasPrivate::get(canvas);
- if (canvasPriv->mouseGrabberItem == q)
+ if (window) {
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window);
+ if (windowPriv->mouseGrabberItem == q)
q->ungrabMouse();
}
effectiveEnable = newEffectiveEnable;
- if (canvas) {
- QQuickCanvasPrivate *canvasPriv = QQuickCanvasPrivate::get(canvas);
- if (canvasPriv->mouseGrabberItem == q)
+ if (window) {
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window);
+ if (windowPriv->mouseGrabberItem == q)
q->ungrabMouse();
if (scope && !effectiveEnable && activeFocus) {
- canvasPriv->clearFocusInScope(
- scope, q, QQuickCanvasPrivate::DontChangeFocusProperty | QQuickCanvasPrivate::DontChangeSubFocusItem);
+ windowPriv->clearFocusInScope(
+ scope, q, QQuickWindowPrivate::DontChangeFocusProperty | QQuickWindowPrivate::DontChangeSubFocusItem);
}
}
(flags & QQuickItem::ItemIsFocusScope) && scope ? q : scope, newEffectiveEnable);
}
- if (canvas && scope && effectiveEnable && focus) {
- QQuickCanvasPrivate::get(canvas)->setFocusInScope(
- scope, q, QQuickCanvasPrivate::DontChangeFocusProperty | QQuickCanvasPrivate::DontChangeSubFocusItem);
+ if (window && scope && effectiveEnable && focus) {
+ QQuickWindowPrivate::get(window)->setFocusInScope(
+ scope, q, QQuickWindowPrivate::DontChangeFocusProperty | QQuickWindowPrivate::DontChangeSubFocusItem);
}
emit q->enabledChanged();
DIRTY_TO_STRING(ChildrenStackingChanged);
DIRTY_TO_STRING(ParentChanged);
DIRTY_TO_STRING(Clip);
- DIRTY_TO_STRING(Canvas);
+ DIRTY_TO_STRING(Window);
DIRTY_TO_STRING(EffectReference);
DIRTY_TO_STRING(Visible);
DIRTY_TO_STRING(HideReference);
+ DIRTY_TO_STRING(Antialiasing);
return rv;
}
if (type & (TransformOrigin | Transform | BasicTransform | Position | Size))
transformChanged();
- if (!(dirtyAttributes & type) || (canvas && !prevDirtyItem)) {
+ if (!(dirtyAttributes & type) || (window && !prevDirtyItem)) {
dirtyAttributes |= type;
- if (canvas && componentComplete) {
+ if (window && componentComplete) {
addToDirtyList();
- QQuickCanvasPrivate::get(canvas)->dirtyItem(q);
+ QQuickWindowPrivate::get(window)->dirtyItem(q);
}
}
}
{
Q_Q(QQuickItem);
- Q_ASSERT(canvas);
+ Q_ASSERT(window);
if (!prevDirtyItem) {
Q_ASSERT(!nextDirtyItem);
- QQuickCanvasPrivate *p = QQuickCanvasPrivate::get(canvas);
+ QQuickWindowPrivate *p = QQuickWindowPrivate::get(window);
nextDirtyItem = p->dirtyItemList;
if (nextDirtyItem) QQuickItemPrivate::get(nextDirtyItem)->prevDirtyItem = &nextDirtyItem;
prevDirtyItem = &p->dirtyItemList;
\property QQuickItem::smooth
\brief Specifies whether the item is smoothed or not
- Primarily used in image based elements to decide if the item should use smooth
+ Primarily used in image based items to decide if the item should use smooth
sampling or not. Smooth sampling is performed using linear interpolation, while
non-smooth is performed using nearest neighbor.
*/
/*!
- Returns true if the item should be drawn with antialiasing and
+ Returns true if the item should be drawn with
smooth pixmap filtering, false otherwise.
- The default is false.
+ The default is true.
\sa setSmooth()
*/
emit smoothChanged(smooth);
}
+/*!
+ \property QQuickItem::antialiasing
+ \brief Specifies whether the item is antialiased or not
+
+ Primarily used in Rectangle and image based elements to decide if the item should
+ use antialiasing or not. Items with antialiasing enabled require more memory and
+ are potentially slower to render.
+
+ The default is false.
+*/
+
+/*!
+ Returns true if the item should be drawn with antialiasing, false otherwise.
+
+ The default is false.
+
+ \sa setAntialiasing()
+*/
+bool QQuickItem::antialiasing() const
+{
+ Q_D(const QQuickItem);
+ return d->antialiasing;
+}
+
+/*!
+ Sets whether the item should be drawn with antialiasing to \a antialiasing.
+
+ \sa antialiasing()
+*/
+void QQuickItem::setAntialiasing(bool antialiasing)
+{
+ Q_D(QQuickItem);
+ if (d->antialiasing == antialiasing)
+ return;
+
+ d->antialiasing = antialiasing;
+ d->dirty(QQuickItemPrivate::Antialiasing);
+
+ emit antialiasingChanged(antialiasing);
+}
+
QQuickItem::Flags QQuickItem::flags() const
{
Q_D(const QQuickItem);
Q_D(QQuickItem);
if ((flags & ItemIsFocusScope) != (d->flags & ItemIsFocusScope)) {
- if (flags & ItemIsFocusScope && !d->childItems.isEmpty() && d->canvas) {
- qWarning("QQuickItem: Cannot set FocusScope once item has children and is in a canvas.");
+ if (flags & ItemIsFocusScope && !d->childItems.isEmpty() && d->window) {
+ qWarning("QQuickItem: Cannot set FocusScope once item has children and is in a window.");
flags &= ~ItemIsFocusScope;
} else if (d->flags & ItemIsFocusScope) {
qWarning("QQuickItem: Cannot unset FocusScope flag.");
Defines the natural width or height of the Item if no \l width or \l height is specified.
- The default implicit size for most items is 0x0, however some elements have an inherent
+ The default implicit size for most items is 0x0, however some items have an inherent
implicit size which cannot be overridden, e.g. Image, Text.
Setting the implicit size is useful for defining components that have a preferred size
if (d->focus == focus)
return;
- if (d->canvas || d->parentItem) {
+ if (d->window || d->parentItem) {
// Need to find our nearest focus scope
QQuickItem *scope = parentItem();
while (scope && !scope->isFocusScope() && scope->parentItem())
scope = scope->parentItem();
- if (d->canvas) {
+ if (d->window) {
if (focus)
- QQuickCanvasPrivate::get(d->canvas)->setFocusInScope(scope, this);
+ QQuickWindowPrivate::get(d->window)->setFocusInScope(scope, this);
else
- QQuickCanvasPrivate::get(d->canvas)->clearFocusInScope(scope, this);
+ QQuickWindowPrivate::get(d->window)->clearFocusInScope(scope, this);
} else {
// do the focus changes from setFocusInScope/clearFocusInScope that are
- // unrelated to a canvas
+ // unrelated to a window
QVarLengthArray<QQuickItem *, 20> changed;
QQuickItem *oldSubFocusItem = QQuickItemPrivate::get(scope)->subFocusItem;
if (oldSubFocusItem) {
changed << this;
emit focusChanged(focus);
- QQuickCanvasPrivate::notifyFocusChangesRecur(changed.data(), changed.count() - 1);
+ QQuickWindowPrivate::notifyFocusChangesRecur(changed.data(), changed.count() - 1);
}
} else {
QVarLengthArray<QQuickItem *, 20> changed;
changed << this;
emit focusChanged(focus);
- QQuickCanvasPrivate::notifyFocusChangesRecur(changed.data(), changed.count() - 1);
+ QQuickWindowPrivate::notifyFocusChangesRecur(changed.data(), changed.count() - 1);
}
}
bool QQuickItem::isUnderMouse() const
{
Q_D(const QQuickItem);
- if (!d->canvas)
+ if (!d->window)
return false;
QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition;
- return contains(mapFromScene(cursorPos)); // ### refactor: d->canvas->mapFromGlobal(cursorPos))))
+ return contains(mapFromScene(d->window->mapFromGlobal(cursorPos.toPoint())));
}
bool QQuickItem::acceptHoverEvents() const
void QQuickItem::grabMouse()
{
Q_D(QQuickItem);
- if (!d->canvas)
+ if (!d->window)
return;
- QQuickCanvasPrivate *canvasPriv = QQuickCanvasPrivate::get(d->canvas);
- if (canvasPriv->mouseGrabberItem == this)
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window);
+ if (windowPriv->mouseGrabberItem == this)
return;
- QQuickItem *oldGrabber = canvasPriv->mouseGrabberItem;
- canvasPriv->mouseGrabberItem = this;
+ QQuickItem *oldGrabber = windowPriv->mouseGrabberItem;
+ windowPriv->mouseGrabberItem = this;
if (oldGrabber) {
QEvent ev(QEvent::UngrabMouse);
- d->canvas->sendEvent(oldGrabber, &ev);
+ d->window->sendEvent(oldGrabber, &ev);
}
}
void QQuickItem::ungrabMouse()
{
Q_D(QQuickItem);
- if (!d->canvas)
+ if (!d->window)
return;
- QQuickCanvasPrivate *canvasPriv = QQuickCanvasPrivate::get(d->canvas);
- if (canvasPriv->mouseGrabberItem != this) {
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window);
+ if (windowPriv->mouseGrabberItem != this) {
qWarning("QQuickItem::ungrabMouse(): Item is not the mouse grabber.");
return;
}
- canvasPriv->mouseGrabberItem = 0;
+ windowPriv->mouseGrabberItem = 0;
QEvent ev(QEvent::UngrabMouse);
- d->canvas->sendEvent(this, &ev);
+ d->window->sendEvent(this, &ev);
}
bool QQuickItem::keepMouseGrab() const
\sa ungrabTouchPoints(), setKeepTouchGrab()
*/
-void QQuickItem::grabTouchPoints(const QList<int> &ids)
+void QQuickItem::grabTouchPoints(const QVector<int> &ids)
{
Q_D(QQuickItem);
- if (!d->canvas)
+ if (!d->window)
return;
- QQuickCanvasPrivate *canvasPriv = QQuickCanvasPrivate::get(d->canvas);
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window);
QSet<QQuickItem*> ungrab;
for (int i = 0; i < ids.count(); ++i) {
- QQuickItem *oldGrabber = canvasPriv->itemForTouchPointId.value(ids.at(i));
+ QQuickItem *oldGrabber = windowPriv->itemForTouchPointId.value(ids.at(i));
if (oldGrabber == this)
return;
- canvasPriv->itemForTouchPointId[ids.at(i)] = this;
+ windowPriv->itemForTouchPointId[ids.at(i)] = this;
if (oldGrabber)
ungrab.insert(oldGrabber);
}
void QQuickItem::ungrabTouchPoints()
{
Q_D(QQuickItem);
- if (!d->canvas)
+ if (!d->window)
return;
- QQuickCanvasPrivate *canvasPriv = QQuickCanvasPrivate::get(d->canvas);
+ QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(d->window);
- QMutableHashIterator<int, QQuickItem*> i(canvasPriv->itemForTouchPointId);
+ QMutableHashIterator<int, QQuickItem*> i(windowPriv->itemForTouchPointId);
while (i.hasNext()) {
i.next();
if (i.value() == this)
QPointF QQuickItem::mapToScene(const QPointF &point) const
{
Q_D(const QQuickItem);
- return d->itemToCanvasTransform().map(point);
+ return d->itemToWindowTransform().map(point);
}
QRectF QQuickItem::mapRectToItem(const QQuickItem *item, const QRectF &rect) const
{
Q_D(const QQuickItem);
- QTransform t = d->itemToCanvasTransform();
+ QTransform t = d->itemToWindowTransform();
if (item)
- t *= QQuickItemPrivate::get(item)->canvasToItemTransform();
+ t *= QQuickItemPrivate::get(item)->windowToItemTransform();
return t.mapRect(rect);
}
QRectF QQuickItem::mapRectToScene(const QRectF &rect) const
{
Q_D(const QQuickItem);
- return d->itemToCanvasTransform().mapRect(rect);
+ return d->itemToWindowTransform().mapRect(rect);
}
QPointF QQuickItem::mapFromItem(const QQuickItem *item, const QPointF &point) const
QPointF QQuickItem::mapFromScene(const QPointF &point) const
{
Q_D(const QQuickItem);
- return d->canvasToItemTransform().map(point);
+ return d->windowToItemTransform().map(point);
}
QRectF QQuickItem::mapRectFromItem(const QQuickItem *item, const QRectF &rect) const
{
Q_D(const QQuickItem);
- QTransform t = item?QQuickItemPrivate::get(item)->itemToCanvasTransform():QTransform();
- t *= d->canvasToItemTransform();
+ QTransform t = item?QQuickItemPrivate::get(item)->itemToWindowTransform():QTransform();
+ t *= d->windowToItemTransform();
return t.mapRect(rect);
}
QRectF QQuickItem::mapRectFromScene(const QRectF &rect) const
{
Q_D(const QQuickItem);
- return d->canvasToItemTransform().mapRect(rect);
+ return d->windowToItemTransform().mapRect(rect);
}
\l {Filter}{Filters} include things like \l {Blur}{blurring}
the item, or giving it a \l Reflection. Some
- filters may not be available on all canvases; if a filter is not
- available on a certain canvas, it will simply not be applied for
- that canvas (but the QML will still be considered valid).
+ filters may not be available on all windows; if a filter is not
+ available on a certain window, it will simply not be applied for
+ that window (but the QML will still be considered valid).
\qml
Item {